package cn.kgc.service;

import cn.kgc.dao.StandardsMapper;
import cn.kgc.pojo.Standards;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StandardsServiceImpl implements StandardsService{
    public StandardsServiceImpl() {
        super();
    }

    @Autowired
    private StandardsMapper standardsMapper;

    public StandardsMapper getStandardsMapper() {
        return standardsMapper;
    }

    public void setStandardsMapper(StandardsMapper standardsMapper) {
        this.standardsMapper = standardsMapper;
    }

    @Override
    //分页展示
    public List<Standards> getListByLimit(String zhname, int currentPageNo, int pageSize) {
        return standardsMapper.getPeopleListLimit(zhname,(currentPageNo-1)*pageSize, pageSize);
    }

    @Override
    //获取总数量
    public int totalCount(String zhname) {
        return standardsMapper.totalCount(zhname);
    }

    @Override
    //通过ID查询
    public Standards getListById(Integer id) {
        return standardsMapper.getListById(id);
    }

    @Override
    //增加
    public boolean add(Standards standards) {
        boolean flag=false;
        try {
            if (standardsMapper.addInfo(standards)==1) {
                flag = true;
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
        return flag;
    }

    @Override
    //修改
    public boolean update(Standards standards) {
        return standardsMapper.update(standards);
    }

    @Override
    //删除
    public boolean delete(Integer id) {
        return standardsMapper.delete(id);
    }
}
